package com.zlcx.tz.live.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;

/**
 * @author anjl
 * 计时学习自习室
 */

@Data
@Entity(name = "tz_time_learn_room")
@JsonSerialize
@DynamicUpdate
@DynamicInsert
public class TimeLearnRoomDO implements Serializable {

    private static final long serialVersionUID = -3712403537202417825L;

    @Id
    @GeneratedValue
    private Long id;

    /**
     * @see TimeLearnRoomType
     * 所属分类
     */
    private Integer type;

    /**
     * 房间名称
     */
    private String roomName;

    /**
     * 房间最大人数
     */
    private Integer roomJoinerMax;

    /**
     * 已占用的座位数量
     */
    private Integer usedSeatsNum;

    /**
     * 座位总数量
     */
    private Integer totalSeatsNum;

    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    public enum TimeLearnRoomType {

        PRIMARY_AND_SECONDARY_SCHOOLS(100, "中小学", 40),
        HIGH_SCHOOL(200, "高中", 40),
        UNIVERSITY(300, "大学", 64),
        ON_THE_JOB(400, "在职", 100),
        ;
        private Integer code;
        private String desc;
        private Integer num;

        public Integer getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        TimeLearnRoomType(Integer code, String desc, Integer num) {
            this.code = code;
            this.desc = desc;
            this.num = num;
        }
    }

}